/*****************************************************************
Mix3D WebGL Game Engine
Copyright (c) fantasy ( fantasy.x2x@gmail.com )
Listens:
Distributed under the Boost Software License, Version 1.0.
http://www.boost.org/LICENSE_1_0.txt
 ****************************************************************/
/**
 * @Desc    : renderable
 * @Author  : fantasy(fantasy.x2x@gmail.com)
 */
//////////////////////////////////////////////////////////////////
if(typeof(Mix3D) === 'undefined')
{
  Mix3D = {};
};
(function(Mix3D){
//////////////////////////////////////////////////////////////////
Mix3D.Renderable = function(geometry, material)
{
  Mix3D.Spatial.call(this);
  
  this.geometry = geometry;
  this.material = (material!==undefined)?material:Mix3D.DefaultMaterial;
  
  this.doubleSided = false;
  this.filpSided = false;
  this.visible = true;
  this.castShadow = false;
  this.receiveShadow = false;
  
  if(this.geometry)
  {
    if(!this.geometry.bound)
    {
      this.geometry.buildBound();
    }
  }
};

Mix3D.Renderable.prototype.constructor = Mix3D.Renderable;

//interface
Mix3D.Renderable.prototype.updateWorldBound = function( )
{
  if(this.geometry)
  {
    this.worldBound.copy(this.geometry.bound);
    this.worldBound.transform(this.worldTransform);
  }
};

Mix3D.Renderable.prototype.getVisibleObject = function( culler, isNoCull) 
{
  culler.insert(this);
};

Mix3D.Renderable.prototype.updateNormals = function()
{
  if(this.geometry)
  {
    this.geometry.buildNormals();
  }
};

Mix3D.Renderable.prototype.updateTangents = function()
{
  if(this.geometry)
  {
    this.geometry.buildTangents();
  }
};

Mix3D.protoCopy(Mix3D.Spatial, Mix3D.Renderable);
//////////////////////////////////////////////////////////////////
})(Mix3D);// end of function(Mix3D)